//
//  Tool.m
//  PantaKill
//
//  Created by 湛凯杰 on 16/7/27.
//  Copyright © 2016年 湛凯杰. All rights reserved.
//

#import "Tool.h"

@implementation Tool
+(BOOL)isLogin{
    if([[NSUserDefaults standardUserDefaults] valueForKey:@"logins"]){
        return YES;
    }else{
        [[NSUserDefaults standardUserDefaults] setObject:@"dui" forKey:@"logins"];
        return NO;
    }
}
+(BOOL)UserNameFormat:(NSString *)userName{
    if (userName.length==11) {
        NSScanner * scan =[NSScanner scannerWithString:userName];
        int val ;
        if ([scan scanInt:&val] && [scan isAtEnd]) {
            return YES;
        }
        else{
           return   NO;
        }
    }
    else{
        return NO;
    }
}

//存储账号
+(void)addUserName:(NSString*)userName{
    [[NSUserDefaults standardUserDefaults] setObject:userName forKey:@"username"];
}
//存储密码
+(void)addPassword:(NSString*)password{
    [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"password"];
}
//取出账号
+(NSString*)GetUserName;
{
    NSString * str=[[NSUserDefaults standardUserDefaults]valueForKey:@"username"];
    return str;
}
//取出密码
+(NSString*)GetPassword{
    NSString * str=[[NSUserDefaults standardUserDefaults]valueForKey:@"password"];
    return str;
}
//产生四位随机数
+(NSString*)getValidationCode{
    int num = (arc4random() % 10000);
   NSString* randomNumber = [NSString stringWithFormat:@"%.4d", num];
    return randomNumber;
}
@end
